home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’95
/
Reminder Manager
/
About.c
next >
Wrap
C/C++ Source or Header
|
1995-06-24
|
2KB
|
100 lines
#include "About.h"
//#define TRUE 1
//#define FALSE 0
#define NIL 0
#define ABOUT 67
static WindowPtr MyWindow;
static Rect picRect;
static int canAbout = TRUE;
void Init_About()
{
MyWindow = NIL;
}
void Close_About()
{
if (MyWindow!=NIL) {
DisposeWindow(MyWindow);
MyWindow = NIL;
}
}
void Update_About()
{
WindowPtr SavePort;
PicHandle Pic_Handle;
Rect tempRect;
SignedByte huhstate;
if (MyWindow!=NIL && canAbout)
{
GetPort(&SavePort);
SetPort(MyWindow);
Pic_Handle = GetPicture(ABOUT);
if (Pic_Handle != NIL)
{
huhstate = HGetState((Handle)Pic_Handle);
MoveHHi((Handle)Pic_Handle);
HLock((Handle)Pic_Handle);
DrawPicture(Pic_Handle,&picRect);
HSetState((Handle)Pic_Handle,huhstate);
}
else {
canAbout = FALSE;
Close_About();
};
SetPort(SavePort);
}
}
void Open_About()
{
PicHandle Pic_Handle;
int v,h;
// I have since seen much simpler code for doing this,
// but I am keeping this stuff for hysterical raisins
if (MyWindow == NIL && canAbout)
{
/* 1. Load the picture */
Pic_Handle = GetPicture(ABOUT);
if (Pic_Handle != NIL) {
HLock((Handle)Pic_Handle);
/* 2. Compute the size and clipping rect */
picRect.top = 0;
picRect.left = 0;
picRect.right = (*Pic_Handle)->picFrame.right
- (*Pic_Handle)->picFrame.left;
picRect.bottom = (*Pic_Handle)->picFrame.bottom
- (*Pic_Handle)->picFrame.top;
HUnlock((Handle)Pic_Handle);
};
/* 3. Load the window */
MyWindow = GetNewWindow(2,NIL, (WindowPtr)-1);
SetPort(MyWindow);
/* 4. resize the window slightly bigger than the PICT */
HLock((Handle)MyWindow);
SizeWindow(MyWindow,picRect.right,picRect.bottom,TRUE);
/* 5. Position the window top third center */
v = ((qd.screenBits.bounds.bottom - qd.screenBits.bounds.top)
- (MyWindow->portRect.bottom - MyWindow->portRect.top)) / 3;
h = ((qd.screenBits.bounds.right - qd.screenBits.bounds.left)
- (MyWindow->portRect.right - MyWindow->portRect.left)) / 2;
MoveWindow(MyWindow,h,v,TRUE);
HUnlock((Handle)MyWindow);
/* 6. Show the window */
ShowWindow(MyWindow);
}
if (MyWindow!=NIL)
SelectWindow(MyWindow);
}